package com.aurora.source.center.presenter;

import android.content.Context;

import com.aurora.source.base.BaseBean;
import com.aurora.source.base.BasePresenter;
import com.aurora.source.center.view.IAddProductView;
import com.aurora.source.constant.AuroraConstants;
import com.aurora.source.util.netutil.SubscriberObserver;

import java.io.File;
import java.util.List;
import java.util.Map;

/**
 * @author: ww
 * @description:
 * @date: 2018/10/8
 */
public class AddProductPresenter extends BasePresenter<IAddProductView>{
    public AddProductPresenter(IAddProductView baseView) {
        super(baseView);
    }

    public void addProductInfo(Map<String, String> params2, List<File> files) {
        requestMethod.addProductInfo(params2,files, new SubscriberObserver<BaseBean>((Context) baseView,"正在添加产品信息...") {
            @Override
            public void onSuccess(BaseBean baseBean) {
                if(baseBean.getCode().equals(AuroraConstants.REQUEST_SUCCESS)){
                    baseView.onAddSuccess(baseBean.getMsg());
                }else {
                    baseView.onAddFail(baseBean.getMsg());
                }
            }

            @Override
            public void onError(String msg) {
                baseView.onAddFail(msg);
            }

            @Override
            public void onFinish() {

            }
        });
    }
}
